package com.websocket.event;

import org.springframework.context.ApplicationEvent;
import org.springframework.lang.Nullable;

import java.security.Principal;

public abstract class AbstractSubProtocolEvent extends ApplicationEvent {

    @Nullable
    private final Principal user;

    /**
     * Create a new AbstractSubProtocolEvent.
     *
     * @param source the component that published the event (never {@code null})
     */
    protected AbstractSubProtocolEvent(Object source, @Nullable Principal user) {
        super(source);
        this.user = user;
    }

    /**
     * Return the user for the session associated with the event.
     */
    @Nullable
    public Principal getUser() {
        return this.user;
    }
}
